package com.wans.user.controller.v1;

import com.wans.common.result.ResponseResult;
import com.wans.model.user.dtos.UserDTO;
import com.wans.user.common.util.UserDTOValidationUtils;
import com.wans.user.service.UserLoginService;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@SuppressWarnings("all")
public class UserLoginController {

    @Autowired
    private UserLoginService userLoginService;

    /**
     * 用户登录请求
     * @param userLoginInfo 登录信息
     * @param response 响应类
     * @return 响应体
     */
    @PostMapping("login")
    public ResponseResult<Void> login(@RequestBody UserDTO userLoginInfo, HttpServletResponse response) {

        // 校验基本数据格式
        UserDTOValidationUtils.validateUserDTO(userLoginInfo);

        return userLoginService.getUser(userLoginInfo);
    }
}
